<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>当前站点首页生成</title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
	<script type="text/javascript" src="${ctx}/js/jquery.progressbar2.js"></script>
	<script type="text/javascript" src="${ctx}/js/publish.js"></script>

</head>
<body>
<s:set name="siteId" value="#session['CURRENT_SITE'].siteId"></s:set>
	<form name="publish_form">
	<s:hidden name="site.siteId"/>
	<s:hidden name="percentKey"/>
<div id="wrapper">
	<div class="curmb">您现在的位置：<a href="${ctx}/main.action">首页</a><span>></span><a href="#">发布管理</a></div>
	<div class="listtit" id="listtit"><p><span><strong>发布</strong><s:if test="site!=null">--当前站点--<font color="red"><s:property value="site.siteName"/></font></s:if></span></p></div>
	<s:if test="site==null">
		<div class="issuecontent">
			<p><span class="issuebg">您还未选择需发布的站点，<br/>请在左侧站点列表选择站点进行操作</span></p>
		</div>
	</s:if><s:else>
		<div class="listoperate whitebg" id="listoperate">
			<span class="space20"></span>
			<a href="#" class="alinks" onclick="publishAll()">全站</a>|
			<a href="#" class="alinks" onclick="publishCat()">栏目</a>|
			<a href="#" class="alinks" onclick="publishTopic()">专题</a>|
			<a href="#" class="alinks" onclick="publishSurvery()">调查</a>|
			<a href="#" class="alinkscurrent" onclick="publishAssociator()">协会理事会</a>
		</div>
		 
		<div class="issuecontent">
			<p>
				<s:if test="%{authLicence('2_2_6',#siteId)}">
					<input type="button" class="btnsave" value="发布" id="publish"/>
				</s:if>
				<s:else>
					<input type="button" class="btnsave" value="发布" id="publish" disabled="disabled"/>
				</s:else>
			</p> 
			<p>发布个私协会理事信息</p>
		</div>
	</s:else>
</div>
</form>
<div id="lightbox_c" class="lightbox" >
	<div class="lighttit"><p><span><input type="button" value="&nbsp;" id="lightclose_c" class="lightclose" /><strong>发  布</strong></span></p></div>
	<div class="lightmain">
		<div class="lightmaintit"><input type="button" value="错误信息" id="changeInfo" class="btnlist2"/><label id="returnInfo">正在发布个私协会理事信息....</label>
		</div>
		<div id="progressBar_bg">
			<span class="progressBar" id="pb2"></span>
			<span id="progressBar_bh"></span>
		</div>
		<div align="right"><input type="button" value="隐藏日志" id="hideInfo" class="btnlist2"/>
		</div>
		<div id="publishInfoAll" align="center">
			<textarea rows="10" cols=60 id="pia" readonly="readonly">aaa</textarea>
		</div>
		<div id="publishInfoError" align="center">
			<textarea rows="10" cols=60 id="pie" readonly="readonly">bbb</textarea>
		</div>
		<div class="lightbtnbox mb25"><input type="button" value="确认" id="lightsubmit_c" class="btnlist2"/><input type="button" value="停止" id="stoppublish" class="btnlist2 ml20"/></div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
	var ctx = '${ctx}';
	$("#hideInfo").click(function(){
		if($(this).val()=="隐藏日志"){
			$(this).val("显示日志");
			$("#publishInfoAll").hide();
			$("#publishInfoError").hide();
		}else{
			$(this).val("隐藏日志");
			$("#publishInfoAll").show();
			$("#publishInfoError").hide();
		}
	});
	$("#changeInfo").click(function(){
		if($(this).val()=="错误信息"){
			$(this).val("全部信息");
			$("#hideInfo").val("隐藏日志");
			$("#publishInfoAll").hide();
			$("#publishInfoError").show();
		}else{
			$(this).val("错误信息");
			$("#hideInfo").val("隐藏日志");
			$("#publishInfoAll").show();
			$("#publishInfoError").hide();
		}
	});
	$("#stoppublish").click(function(){
		stopPublish();
	});
	var now = '<s:property value="now"/>';
	$("#publish").click(function(){
		$("#stoppublish").attr("disabled","");
		$$.shade("#publish","#lightclose_c,#lightsubmit_c","#lightbox_c","350");
		publishAssociators();
	});
	$("#lightclose_c").click(function(){
		initBar();
	});
	$("#lightsubmit_c").click(function(){
		initBar();
	});
	function initBar(){
		$('#pb2').progressBar(0);
	}
	$(document).ready(function (){
		$("#publish_index").hide();
		$("#publish_more").hide();
		$("#pb2").progressBar({ barImage: '../images/progressbg_yellow2.gif'} );
	});
	$("input[name=website]").click(function(){
		$(this).each(function(){
			if($(this).attr("checked")==true){
				if($(this).val()=="index"){
					$("#publish_all").hide();
					$("#publish_index").show();
					$("#publish_more").hide();
				}
				if($(this).val()=="all"){
					$("#publish_all").show();
					$("#publish_index").hide();
					$("#publish_more").hide();
				}
				if($(this).val()=="more"){
					$("#publish_all").hide();
					$("#publish_index").hide();
					$("#publish_more").show();
				}
			}
		});
		
	});
	function publishAll(){
		$("form[name=publish_form]").attr("action","${ctx}/generate/list-site.action");
		$("form[name=publish_form]").submit();
	}
	function publishCat(){
		$("form[name=publish_form]").attr("action","${ctx}/generate/list-cat.action");
		$("form[name=publish_form]").submit();
	}
	function publishTopic(){
		$("form[name=publish_form]").attr("action","${ctx}/generate/list-topic.action");
		$("form[name=publish_form]").submit();
	}
	function publishSurvery(){
		$("form[name=publish_form]").attr("action","${ctx}/generate/list-survey.action");
		$("form[name=publish_form]").submit();
	}
	function publishAssociator(){
		$("form[name=publish_form]").attr("action","${ctx}/generate/list-associator.action");
		$("form[name=publish_form]").submit();
	}
	function publishAssociators(){
		$("#returnInfo").html("正在发布理事会信息....");
		$("#lightsubmit_c").attr("disabled","disabled");
		
		$.ajax({	
			url:ctx+"/generate/publish.action",
			data:{"type":"associator",
				  "pflag":'1'},
			dataType:"text",
			type:"post",
			success:function(data){
				var json = eval('('+data+')');
				if(json.flag){
					returnValue(json.id);
				}else{
					alert("发布失败！");
				}
			},
			error:function(data){
				alert("发布遇到错误！点击继续发布下一个任务");
			}
		});
	}
</script>